<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- Copyright © 1988-2023 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Funding Free Software", the Front-Cover
Texts being (a) (see below), and with the Back-Cover Texts being (b)
(see below).  A copy of the license is included in the section entitled
"GNU Free Documentation License".

(a) The FSF's Front-Cover Text is:

A GNU Manual

(b) The FSF's Back-Cover Text is:

You have freedom to copy and modify this GNU Manual, like GNU
     software.  Copies published by the Free Software Foundation raise
     funds for GNU development. -->
<title>Statement and operand traversals (GNU Compiler Collection (GCC) Internals)</title>

<meta name="description" content="Statement and operand traversals (GNU Compiler Collection (GCC) Internals)">
<meta name="keywords" content="Statement and operand traversals (GNU Compiler Collection (GCC) Internals)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">

<link href="index.html" rel="start" title="Top">
<link href="Option-Index.html" rel="index" title="Option Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="GIMPLE.html" rel="up" title="GIMPLE">
<link href="Adding-a-new-GIMPLE-statement-code.html" rel="prev" title="Adding a new GIMPLE statement code">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
div.example {margin-left: 3.2em}
span:hover a.copiable-link {visibility: visible}
strong.def-name {font-family: monospace; font-weight: bold; font-size: larger}
-->
</style>


</head>

<body lang="en">
<div class="section-level-extent" id="Statement-and-operand-traversals">
<div class="nav-panel">
<p>
Previous: <a href="Adding-a-new-GIMPLE-statement-code.html" accesskey="p" rel="prev">Adding a new GIMPLE statement code</a>, Up: <a href="GIMPLE.html" accesskey="u" rel="up">GIMPLE</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h3 class="section" id="Statement-and-operand-traversals-1"><span>12.12 Statement and operand traversals<a class="copiable-link" href="#Statement-and-operand-traversals-1"> &para;</a></span></h3>
<a class="index-entry-id" id="index-Statement-and-operand-traversals"></a>

<p>There are two functions available for walking statements and
sequences: <code class="code">walk_gimple_stmt</code> and <code class="code">walk_gimple_seq</code>,
accordingly, and a third function for walking the operands in a
statement: <code class="code">walk_gimple_op</code>.
</p>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-walk_005fgimple_005fstmt"><span class="category-def">GIMPLE function: </span><span><code class="def-type">tree</code> <strong class="def-name">walk_gimple_stmt</strong> <code class="def-code-arguments">(gimple_stmt_iterator *gsi,   walk_stmt_fn callback_stmt, walk_tree_fn callback_op, struct walk_stmt_info *wi)</code><a class="copiable-link" href="#index-walk_005fgimple_005fstmt"> &para;</a></span></dt>
<dd><p>This function is used to walk the current statement in <code class="code">GSI</code>,
optionally using traversal state stored in <code class="code">WI</code>.  If <code class="code">WI</code> is <code class="code">NULL</code>, no
state is kept during the traversal.
</p>
<p>The callback <code class="code">CALLBACK_STMT</code> is called.  If <code class="code">CALLBACK_STMT</code> returns
true, it means that the callback function has handled all the
operands of the statement and it is not necessary to walk its
operands.
</p>
<p>If <code class="code">CALLBACK_STMT</code> is <code class="code">NULL</code> or it returns false, <code class="code">CALLBACK_OP</code> is
called on each operand of the statement via <code class="code">walk_gimple_op</code>.  If
<code class="code">walk_gimple_op</code> returns non-<code class="code">NULL</code> for any operand, the remaining
operands are not scanned.
</p>
<p>The return value is that returned by the last call to
<code class="code">walk_gimple_op</code>, or <code class="code">NULL_TREE</code> if no <code class="code">CALLBACK_OP</code> is specified.
</p></dd></dl>


<dl class="first-deftypefn">
<dt class="deftypefn" id="index-walk_005fgimple_005fop"><span class="category-def">GIMPLE function: </span><span><code class="def-type">tree</code> <strong class="def-name">walk_gimple_op</strong> <code class="def-code-arguments">(gimple stmt,   walk_tree_fn callback_op, struct walk_stmt_info *wi)</code><a class="copiable-link" href="#index-walk_005fgimple_005fop"> &para;</a></span></dt>
<dd><p>Use this function to walk the operands of statement <code class="code">STMT</code>.  Every
operand is walked via <code class="code">walk_tree</code> with optional state information
in <code class="code">WI</code>.
</p>
<p><code class="code">CALLBACK_OP</code> is called on each operand of <code class="code">STMT</code> via <code class="code">walk_tree</code>.
Additional parameters to <code class="code">walk_tree</code> must be stored in <code class="code">WI</code>.  For
each operand <code class="code">OP</code>, <code class="code">walk_tree</code> is called as:
</p>
<div class="example smallexample">
<pre class="example-preformatted">walk_tree (&amp;<code class="code">OP</code>, <code class="code">CALLBACK_OP</code>, <code class="code">WI</code>, <code class="code">PSET</code>)
</pre></div>

<p>If <code class="code">CALLBACK_OP</code> returns non-<code class="code">NULL</code> for an operand, the remaining
operands are not scanned.  The return value is that returned by
the last call to <code class="code">walk_tree</code>, or <code class="code">NULL_TREE</code> if no <code class="code">CALLBACK_OP</code> is
specified.
</p></dd></dl>


<dl class="first-deftypefn">
<dt class="deftypefn" id="index-walk_005fgimple_005fseq"><span class="category-def">GIMPLE function: </span><span><code class="def-type">tree</code> <strong class="def-name">walk_gimple_seq</strong> <code class="def-code-arguments">(gimple_seq seq,   walk_stmt_fn callback_stmt, walk_tree_fn callback_op, struct walk_stmt_info *wi)</code><a class="copiable-link" href="#index-walk_005fgimple_005fseq"> &para;</a></span></dt>
<dd><p>This function walks all the statements in the sequence <code class="code">SEQ</code>
calling <code class="code">walk_gimple_stmt</code> on each one.  <code class="code">WI</code> is as in
<code class="code">walk_gimple_stmt</code>.  If <code class="code">walk_gimple_stmt</code> returns non-<code class="code">NULL</code>, the walk
is stopped and the value returned.  Otherwise, all the statements
are walked and <code class="code">NULL_TREE</code> returned.
</p></dd></dl>


</div>
<hr>
<div class="nav-panel">
<p>
Previous: <a href="Adding-a-new-GIMPLE-statement-code.html">Adding a new GIMPLE statement code</a>, Up: <a href="GIMPLE.html">GIMPLE</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>
